Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polygon-clipping

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polygon-clipping

Apply boolean Polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.

  • 0.14.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
494K
decreased by-3.15%
Maintainers
1
Weekly downloads
 
Created

What is polygon-clipping?

The polygon-clipping npm package is a library for performing boolean operations on polygons, such as union, intersection, difference, and xor. It is useful for computational geometry tasks, particularly in GIS (Geographic Information Systems) and CAD (Computer-Aided Design) applications.

What are polygon-clipping's main functionalities?

Union

The union operation combines two or more polygons into a single polygon that covers the area of all input polygons.

const polygonClipping = require('polygon-clipping');
const polygon1 = [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]];
const polygon2 = [[[2, 2], [6, 2], [6, 6], [2, 6], [2, 2]]];
const union = polygonClipping.union(polygon1, polygon2);
console.log(union);

Intersection

The intersection operation finds the overlapping area between two or more polygons.

const polygonClipping = require('polygon-clipping');
const polygon1 = [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]];
const polygon2 = [[[2, 2], [6, 2], [6, 6], [2, 6], [2, 2]]];
const intersection = polygonClipping.intersection(polygon1, polygon2);
console.log(intersection);

Difference

The difference operation subtracts the area of one polygon from another, resulting in the parts of the first polygon that are not overlapped by the second polygon.

const polygonClipping = require('polygon-clipping');
const polygon1 = [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]];
const polygon2 = [[[2, 2], [6, 2], [6, 6], [2, 6], [2, 2]]];
const difference = polygonClipping.difference(polygon1, polygon2);
console.log(difference);

XOR

The XOR operation finds the areas that are covered by either of the polygons but not by both.

const polygonClipping = require('polygon-clipping');
const polygon1 = [[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]]];
const polygon2 = [[[2, 2], [6, 2], [6, 6], [2, 6], [2, 2]]];
const xor = polygonClipping.xor(polygon1, polygon2);
console.log(xor);

Other packages similar to polygon-clipping

Keywords

FAQs

Package last updated on 26 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc